home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
pibt40s1.arc
/
GETAREAC.MOD
< prev
next >
Wrap
Text File
|
1987-03-16
|
6KB
|
168 lines
(*--------------------------------------------------------------------------*)
(* GetAreaCode --- Get area code for city/state/country *)
(*--------------------------------------------------------------------------*)
PROCEDURE GetAreaCode;
(*--------------------------------------------------------------------------*)
(* *)
(* Procedure: GetAreaCode *)
(* *)
(* Purpose: Searches area code directory *)
(* *)
(* Calling sequence: *)
(* *)
(* GetAreaCode; *)
(* *)
(* Calls: *)
(* *)
(* UpperCase *)
(* Save_Screen *)
(* Draw_Menu_Frame *)
(* Restore_Screen *)
(* Reset_Global_Colors *)
(* *)
(* Called by: Execute_Command *)
(* *)
(* Credit: This area code search is based upon one by Tom Hanlin III *)
(* in his ETERM and PASCTERM programs, and one by Martin Smith *)
(* in his AREA2.EXE program. *)
(* *)
(*--------------------------------------------------------------------------*)
CONST
MaxAreaCodes = 300;
VAR
LF : BYTE;
RT : BYTE;
Ptr : BYTE;
I : BYTE;
Code : STRING[20];
Any_Ch : CHAR;
AreaCode : ARRAY[0..MaxAreaCodes] OF STRING[60];
AreaCodeFile : TEXT[1024];
N_Area_Codes : INTEGER;
Searching_Done : BOOLEAN;
(*--------------------------------------------------------------------------*)
PROCEDURE Do_Area_Code_Search;
BEGIN (* Searching_Done *)
(* Convert to upper case *)
Code := UpperCase( Code );
(* Determine type of request *)
IF ( RT = 2 ) AND
( Code[1] IN ['A'..'Z']) AND ( Code[2] IN ['A'..'Z'] ) THEN
LF := 4
ELSE IF ( RT = 3 ) AND
( Code[1] IN ['0'..'9'] ) AND
( Code[2] IN ['0'..'9'] ) AND
( Code[3] IN ['0'..'9'] ) THEN
LF := 1
ELSE IF RT <> 0 THEN
LF := 6;
(* Display search message *)
Draw_Menu_Frame( 5, 4, 75, 23, Menu_Frame_Color, Menu_Title_Color,
Menu_Text_Color, 'Searching for: ' + Code );
(* Perform search *)
View_Count := 0;
View_Done := FALSE;
FOR I := 0 TO N_Area_Codes DO
IF ( NOT View_Done ) THEN
IF UpperCase( Copy( AreaCode[I], LF, RT ) ) = Code THEN
BEGIN
WRITE ( ' ' );
WRITE ( Copy( AreaCode[I], 1, 3 ), ' ' );
WRITE ( Copy( AreaCode[I], 4, 2 ) ,' ' );
WRITELN( Copy( AreaCode[I], 6, LENGTH( AreaCode[I] ) - 5 ) );
View_Count := View_Count + 1;
IF View_Count > 16 THEN
View_Prompt( View_Done, View_Count );
END;
RvsVideoOn ( Menu_Text_Color , BLACK );
WRITE('Search complete. Hit any key to continue.');
RvsVideoOff( Menu_Text_Color , BLACK );
Read_Kbd( Any_Ch );
IF ( Any_Ch = CHR( ESC ) ) AND KeyPressed THEN
READ( Kbd, Any_Ch );
END (* Searching_Done *);
(*--------------------------------------------------------------------------*)
BEGIN (* GetAreaCode *)
(* Save current screen *)
Save_Screen( Saved_Screen );
(* Display area code prompt box *)
Draw_Menu_Frame( 5, 4, 75, 23, Menu_Frame_Color, Menu_Title_Color,
Menu_Text_Color, 'Area code search' );
(* Open area code directory file *)
ASSIGN( AreaCodeFile , Home_Dir + 'PIBTERM.ACO' );
(*$I-*)
RESET ( AreaCodeFile );
(*$I+*)
(* Check if open went OK *)
IF ( Int24Result <> 0 ) THEN
BEGIN
WRITELN('Area code file ', Home_Dir, ' PIBTERM.ACO cannot be opened.');
WRITELN;
DELAY( Two_Second_Delay );
Restore_Screen( Saved_Screen );
Reset_Global_Colors;
EXIT;
END;
(* Read in area code data *)
WRITELN('Reading area code information ... ');
N_Area_Codes := -1;
REPEAT
N_Area_Codes := N_Area_Codes + 1;
READLN( AreaCodeFile , AreaCode[N_Area_Codes] );
UNTIL ( EOF( AreaCodeFile ) );
(*$I-*)
CLOSE( AreaCodeFile );
(*$I+*)
(* Prompt for and read area code req. *)
Searching_Done := FALSE;
REPEAT
Clear_Window;
WRITE('Enter area code, state/country, or state initials: ');
Code := '';
Read_Edited_String( Code );
RT := LENGTH( Code );
IF ( ( RT > 0 ) AND ( Code <> CHR( ESC ) ) ) THEN
Do_Area_Code_Search
ELSE
Searching_Done := TRUE;
UNTIL( Searching_Done );
(* Restore previous screen *)
Restore_Screen( Saved_Screen );
Reset_Global_Colors;
END (* GetAreaCode *);